
<div class="moduleTopNav clearfix">
	<div class="fl-l">
		<?php $module->printAddLink($lang->get('add-page')); ?>
	</div>
	<div class="fl-r">
		<?php
		
		$published = (isset($_REQUEST['published'])) ? $_REQUEST['published'] : true;
		echo '<strong>'.$lang->get('published').'</strong> ';
		$module->printBoolDropdown('published', $published, 'window.location=\''.$cosa->system('base-url').'/?m='.$m.'&s='.$s.'&published=\'+this.value');
		
		?>
	</div>
</div>

<table class="datatable">
	<thead>
		<tr>
			<td>&nbsp;</td>
			<td><?php $module->printSortLink($lang->get('title'), 'title'); ?></td>
			<td><?php $module->printSortLink($lang->get('text'), 'text'); ?></td>
			<td><?php $module->printSortLink($lang->get('author'), 'created_by'); ?></td>
			<td><?php $module->printSortLink($lang->get('time-created'), 'time_created'); ?></td>
			<td><?php $lang->put('history'); ?></td>
		</tr>
	</thead>
	<tbody>
		<?php
		
		$structure = array('publish', 'title', 'text', 'author', 'time_created', 'version_info');
		$module->setStructure($structure);
		
		$res = $module->queryData("SELECT * FROM ".$db->module('pages')); //." WHERE published='".$published."'");
		
		if(mysql_num_rows($res)) {
			while($row = mysql_fetch_array($res)) {
				
				$publishLink = ($user->group_id == 1) ? ' (<a href="'.$cosa->system('base-url').'/?m='.$m.'&s='.$s.'&publish='.stripslashes($row['id']).'">'.$lang->get('publish').'</a>)' : '';
				$status = ($row['published']) ? $lang->get('published') : $lang->get('draft').$publishLink;
				
				$data = array(	'id'				=> stripslashes($row['id'])
								,'publish'			=> $status
								,'title'			=> stripslashes($row['title'])
								,'text'				=> substr(strip_tags(stripslashes($row['text'])), 0, 70).'...'
								,'author'			=> $user->authorLink($row['created_by'])
								,'time_created'		=> $cosa->datetime($row['time_created'])
								,'version_info'		=> '<a href="'.$cosa->system('base-url').'/?m='.$m.'&s=history&pid='.stripslashes($row['id']).'">'.$lang->get('version-history').'</a>'
								);
				$module->printTableRow($data);
				
			}
		} else {
			$module->printEmptyTableRow($lang->get('no-items-found'));
		}
		
		?>
	</tbody>
</table>
